package com.chen.controller;

import com.chen.base.ResponseResult;
import com.chen.dto.RoomDto;
import com.chen.service.RoomService;
import com.chen.vo.RoomVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 房间管理
 */
@RestController
@RequestMapping("/room")
public class RoomController extends BaseController {
    @Resource
    private RoomService roomService;

    /**
     * 添加房间
     * @param roomDto roomDto
     * @return
     */
    @PostMapping("/add")
    public ResponseResult addRoom(@RequestBody RoomDto roomDto) {
        return toAjax(roomService.addRoom(roomDto));
    }

    /**
     * 删除房间
     * @param id id
     * @return
     */
    @DeleteMapping("/delete/{id}")

    public ResponseResult deleteRoom(@PathVariable Long id) {
        return toAjax(roomService.deleteRoom(id));
    }

    /**
     * 更新房间
     * @param roomDto 房间dto
     * @return
     */
    @PutMapping("/update")
    public ResponseResult updateRoom(@RequestBody RoomDto roomDto) {
        return toAjax(roomService.updateRoom(roomDto));
    }

    /**
     * 获取房间
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    public ResponseResult<RoomVo> getRoom(@PathVariable Long id) {
        return ResponseResult.success(roomService.getRoom(id));
    }

    /**
     * 获取所有房间（所有楼层）
     * @return
     */
    @GetMapping("/getAllVo")
    public ResponseResult<List<RoomVo>> getAllRoomVos() {
        return ResponseResult.success(roomService.getAllRoomVos());
    }

    /**
     * 获取所有房间（入住配置）
     * @param floorId id
     * @return
     */
    @GetMapping("/getRoomsByFloorId/{floorId}")
    public ResponseResult<List<RoomVo>> getRoomsByFloorId(@PathVariable Long floorId) {
        return ResponseResult.success(roomService.getRoomsByFloorId(floorId));
    }

    /**
     * 获取所有房间（床位房型）
     * @param floorId
     * @return
     */
    @GetMapping("/getRoomsCheckedByFloorId/{floorId}")
    public ResponseResult<List<RoomVo>> getRoomsCheckedByFloorId(@PathVariable Long floorId) {
        return ResponseResult.success(roomService.getRoomsCheckedByFloorId(floorId));
    }

    /**
     * 获取所有房间（智能床位）
     * @param floorId
     * @return
     */
    @GetMapping("/getRoomsWithDeviceByFloorId/{floorId}")
    public ResponseResult<List<RoomVo>> getRoomsWithDeviceByFloorId(@PathVariable Long floorId) {
        return ResponseResult.success(roomService.getRoomsWithDeviceByFloorId(floorId));
    }

    /**
     * 获取所有房间（负责老人）
     * @param floorId id
     * @return
     */
    @GetMapping("/getRoomsWithNurByFloorId/{floorId}")
    public ResponseResult<List<RoomVo>> getRoomsWithNurByFloorId(@PathVariable Long floorId) {
        return ResponseResult.success(roomService.getRoomsWithNurByFloorId(floorId));
    }
}
